package common.view;

import javax.swing.JPanel;
import javax.swing.SpringLayout;
import javax.swing.JLabel;
import javax.swing.JComboBox;
import java.awt.Font;
import java.awt.Dimension;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.JList;
import javax.swing.JTable;
import javax.swing.AbstractListModel;
import javax.swing.table.DefaultTableModel;

public class NotificationsView extends JPanel 
{
	private JTable table;
	private JButton btnSave;
	private JComboBox comboBoxSelect;
	
	public NotificationsView() 
	{
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		
		JLabel lblSelect = new JLabel("Select :");
		lblSelect.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, lblSelect, 10, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, lblSelect, 10, SpringLayout.WEST, this);
		add(lblSelect);
		
		comboBoxSelect = new JComboBox();
		comboBoxSelect.setPreferredSize(new Dimension(200, 20));
		comboBoxSelect.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, comboBoxSelect, 10, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, comboBoxSelect, 6, SpringLayout.EAST, lblSelect);
		add(comboBoxSelect);
		
		btnSave = new JButton("Save");
		btnSave.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.WEST, btnSave, 300, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.SOUTH, btnSave, -10, SpringLayout.SOUTH, this);
		add(btnSave);
		
		JScrollPane scrollPaneTable = new JScrollPane();
		springLayout.putConstraint(SpringLayout.WEST, scrollPaneTable, 0, SpringLayout.WEST, btnSave);
		springLayout.putConstraint(SpringLayout.SOUTH, scrollPaneTable, -10, SpringLayout.NORTH, btnSave);
		springLayout.putConstraint(SpringLayout.NORTH, scrollPaneTable, 10, SpringLayout.SOUTH,comboBoxSelect);
		springLayout.putConstraint(SpringLayout.EAST, scrollPaneTable, -10, SpringLayout.EAST,this);
		add(scrollPaneTable);
		
		JScrollPane scrollPaneList = new JScrollPane();
		springLayout.putConstraint(SpringLayout.NORTH, scrollPaneList, 10, SpringLayout.SOUTH,comboBoxSelect);
		springLayout.putConstraint(SpringLayout.WEST, scrollPaneList, 10, SpringLayout.WEST, this);
		springLayout.putConstraint(SpringLayout.SOUTH, scrollPaneList, 0, SpringLayout.SOUTH,scrollPaneTable);
		springLayout.putConstraint(SpringLayout.EAST, scrollPaneList, -10, SpringLayout.WEST,scrollPaneTable);
		
		table = new JTable();
		table.setModel(new DefaultTableModel(
			new Object[][] {
				{null, null, null, null, null, null},
			},
			new String[] {
				"New column", "New column", "New column", "New column", "New column", "New column"
			}
		));
		scrollPaneTable.setViewportView(table);
		add(scrollPaneList);
		
		JList list = new JList();
		list.setModel(new AbstractListModel() {
			String[] values = new String[] {"listItem 1", "listItem 2", "listItem 3", "listItem 4"};
			public int getSize() {
				return values.length;
			}
			public Object getElementAt(int index) {
				return values[index];
			}
		});
		scrollPaneList.setViewportView(list);
	}
}
